Release 10.1A: OpenEdge Development:
Programming Interfaces
SAX callback reference
This section contains a reference entry for each callback Progress SAX supports. Each entry specifies the signature and defines each parameter.
The callbacks, in alphabetical order, are:
These callbacks closely match those defined in the SAX2 documentation at
www.saxproject.org. For more information on these callbacks, see this Web site.Characters
Invoked when the XML parser detects character data.
charDataA
MEMPTRorLONGCHARthat contains a chunk of character data.numCharsThe number of characters contained in the
Note: If a character requires more than one byte to encode, the value of numChars might not match the value returned byMEMPTR.MEMPTR:GETSIZE().The parser calls this method to report each chunk of character data. It might report contiguous character data in one chunk, or split it into several chunks. If validation is enabled, whitespace is reported by the IgnorableWhitespace callback.
Although it is not intended for the application to call Characters directly, the application can. Whoever calls Characters must free the charData
MEMPTR. When Progress calls Characters, Progress is responsible for freeing thecharDataMEMPTR(although if the application frees it, no harm results). If the application calls Characters, the application is responsible for freeing thecharDataMEMPTR.To copy the
charData MEMPTRsuch that the memory used by the copy is completely separate from the memory used by the original, use 4GL assignment, which performs a deep copy. The following fragment demonstrates this:
For more information on 4GL assignment, see the OpenEdge Development: Progress 4GL Reference .
EndDocument
Invoked when the XML parser detects the end of an XML document.
EndElement
Invoked when the XML parser detects the end of an element.
namespaceURIA
CHARACTERstring indicating the namespace URI of the element.If namespace processing is not enabled, or the element is not part of a namespace, the string is of length zero.
localNameA
CHARACTERstring indicating the nonprefixed element name.If namespace processing is not enabled, the string is of length zero.
qNameA
CHARACTERstring indicating the actual name of the element in the XML source.If the name has a prefix,
qNameincludes it, whether or not namespace processing is enabled.This callback corresponds to a preceding StartElement after all element content is reported.
EndPrefixMapping
Invoked when the XML parser detects that a prefix associated with namespace mapping has gone out of scope.
prefixA character string representing the prefix for a namespace declaration.
This callback is invoked only when namespace processing is enabled. It provides information not required by normal namespace processing. However, in some situations, this callback might be useful and even required.
Error
Invoked to report an error encountered by the parser while parsing the XML document.
errMessageA character string indicating the error message.
After this callback is invoked, the parser continues where it left off.
FatalError
Invoked to report a fatal error.
errMessageA character string indicating the error message.
The application must assume that after a fatal error is reported, the document is unusable and future parsing events might not be reported. However, the parser might try to continue to parse the document. To stop the parser after reporting a fatal error, execute
Note: If you stop the parser by executingRETURNERROR.STOP-PARSING(), parsing stops, but no error condition is raised, no error message is reported,SAX-reader’sPARSE-STATUSattribute is set toSAX-COMPLETErather than toSAX-PARSER-ERROR, and the driver might not know that an error occurred. For this reason, Progress Software Corporation recommends that to stop the parser after reporting a fatal error, executeRETURNERROR.IgnorableWhitespace
Invoked when the XML parser detects ignorable whitespace.
charDataA
CHARACTERstring representing a contiguous block of ignorable whitespace in an XML document.numCharsAn
INTEGERexpression indicating the size, in characters, of the character string.If validation is enabled, the XML parser reports ignorable whitespace through this callback. If validation is not enabled, the XML parser reports whitespace through the Characters callback.
The data type of
charDataisCHARACTER, notMEMPTR, because it is unlikely that an XML document has over 32K of contiguous ignorable whitespace.NotationDecl
Invoked when the XML parser detects a notation declaration.
nameA character string representing the name of the notation.
publicIDOptional. A character string indicating the public identifier of the entity.
If none is supplied, the string is of length zero.
systemIDOptional. A character string indicating the system identifier of the entity.
If none is supplied, the string is of length zero.
systemIDmust be one of the following:ProcessingInstruction
Invoked when the XML parser detects a processing instruction.
targetA character string indicating the target of the processing instruction.
dataA character string indicating the data associated with the processing instruction.
If the processing instruction has no data, the length of the string is zero.
Note: A processing instructions can appear before or after a root element.ResolveEntity
Invoked to let the application specify the location of an external entity (such as a DTD or XML schema).
When the parser finds an external entity reference, it calls ResolveEntity, passing it the system identifier and public identifier (if any) contained in the XML. This gives the application a chance to override the location specified in the XML.
Note: In ResolveEntity, you cannot use any I/O blocking statements, such as theUPDATEstatement and theWAIT-FORstatement.
publicIDOptional. A character string indicating the public identifier of the entity. If none is supplied, the string is of length zero.
systemIDA character string indicating the system identifier of the entity.
The character string will not be of length zero, as this parameter is required.
systemIDwill be one of the following:filePathOptional. A character string indicating the actual location of the entity being resolved. This tells the parser where to actually get the entity, in preference to the location specified by the system identifier.
filePathwill be one of the following:memPointerOptional. A
MEMPTRorLONGCHARcontaining the entity being resolved. UsememPointerto return XML representing an entity that is not stored as a stand-alone file.If you do not supply
Caution: Supplying bothmemPointer, set it to the Unknown value (?).filePathandmemPointeris an error.If the application does not implement this callback, or if the callback sets both
filePathandmemPointerto the Unknown value (?), the entity is resolved according to the following rules (which are also the rules that the Progress XML DOM interface uses):
- If the location given in the XML source is a relative path and the
SAX-reader:SCHEMA-PATHattribute has been set, try appending the relative path to each entry inSCHEMA-PATHand retrieving the file there.- If the location is a relative file path and the
SAX-reader:SCHEMA-PATHattribute has the Unknown value (?), try retrieving the file relative to the working directory.- If the location given in the XML source is an absolute path to a local file or if it is an HTTP URI, try retrieving the file at the specified location.
- If the file cannot be found, Progress calls the FatalError callback (if there is one) and stops processing the XML.
StartDocument
Invoked when the XML parser detects the start of an XML document.
StartDocument does not provide any data.
StartElement
Invoked when the XML parser detects the beginning of an element.
namespaceURIA character string indicating the namespace URI of the element.
If namespace processing is not enabled or the element is not part of a namespace, the string is of length zero.
localNameA character string indicating the non-prefixed element name.
If namespace processing is not enabled, the string is of length zero.
qNameA character string indicating the actual name of the element in the XML source.
If the name has a prefix,
qNameincludes it, whether or not namespace processing is enabled.attributesA handle to a
SAX-attributesobject, which provides access to all attributes specified for the element.If the element has no attributes,
attributesis still a valid handle, and theNUM-ITEMSattribute is zero.For every invocation of StartElement, there is a corresponding invocation of EndElement.
The contents of the element are reported in sequential order before the corresponding EndElement is invoked.
When StartElement returns, the SAX-attributeS object, which was created by Progress, is deleted by Progress.
Note: If the application deletes it first, however, no harm is done.StartPrefixMapping
Invoked when the XML parser detects that a prefix associated with namespace mapping is coming into scope.
Note: This callback is invoked only when namespace processing is enabled.
prefixA character string representing the prefix for a namespace declaration.
uriA character string representing the URI that identifies the namespace being declared.
This callback does not normally need to be implemented, since the information it provides is not required for normal namespace processing. But it might be useful, and even required, in some situations.
UnparsedEntityDecl
Invoked when the XML parser detects an entity that it does not parse (where “unparsed entity” has the definition given in the XML 1.0 specification).
nameA character string indicating the name of the entity.
publicIDOptional. A character string indicating the public identifier of the entity.
If
publicIDis not supplied, the character string is of length zero.systemIDOptional. A character string representing the system identifier of the entity.
If
systemIDis not supplied, the character string is of length zero.
systemIDmust be one of the following:notationNameA character string indicating the name of the notation associated with the entity.
Warning
Invoked to report a warning.
errMessageA character string indicating the error message.
A warning is a condition that is less severe than an error or a fatal error, as determined by the XML parser.
After this callback is invoked, the parser continues where it left off.
|
Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |